package leetcode;

import java.util.Arrays;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0377.java
 * @Author : WangRuoyu
 * @Date 2023/11/24 22:52
 */

public class Q0377 {
    public int combinationSum4(int[] nums, int target) {
        int[] f = new int[target + 1];
        f[0] = 1;
        for (int i = 1; i <= target; i++) {
            for (int num : nums) {
                if (num <= i) f[i] += f[i - num];
            }
        }
        return f[target];
    }

    public static void main(String[] args) {
        Q0377 sl = new Q0377();
        System.out.println(sl.combinationSum4(new int[]{1, 2, 3}, 4));
    }
}